﻿Public Class fListaParaArmarPrepacks
    Private lDtDatos As lbGlobalcom.dsMovimiento.MOV_MOVIMIENTODETALLEDataTable
    Private lCodigo As String
    Private lItem As Int16
    Public Property Datos() As lbGlobalcom.dsMovimiento.MOV_MOVIMIENTODETALLEDataTable
        Get
            Return lDtDatos
        End Get
        Set(ByVal value As lbGlobalcom.dsMovimiento.MOV_MOVIMIENTODETALLEDataTable)
            lDtDatos = value
            gvDatos.DataSource = lDtDatos
        End Set
    End Property
    Public ReadOnly Property CodigoProd() As String
        Get
            Return lCodigo
        End Get
    End Property
    Public ReadOnly Property ItemProd() As Int16
        Get
            Return lItem
        End Get
    End Property

    Private Sub gvDatos_CellDoubleClick(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles gvDatos.CellDoubleClick
        If gvDatos.CurrentRow IsNot Nothing Then
            lCodigo = gvDatos.CurrentRow.Cells("IDPRODUCTO").Value
            lItem = gvDatos.CurrentRow.Cells("NUMEROLINEA").Value
            Me.DialogResult = Windows.Forms.DialogResult.OK
        End If
    End Sub

    Private Sub AsignaPrepack(ByVal Fila As Integer)
        If Fila >= 0 Then
            lCodigo = gvDatos.Rows(Fila).Cells("IDPRODUCTO").Value
            lItem = gvDatos.Rows(Fila).Cells("NUMEROLINEA").Value
            Me.DialogResult = Windows.Forms.DialogResult.OK
        End If
    End Sub


    Private Sub gvDatos_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles gvDatos.KeyDown
        If e.KeyData = Keys.Enter Then
            AsignaPrepack(gvDatos.CurrentRow.Index)
        End If
    End Sub
End Class